<template>
	<view class="page">
		<QRcode @ok="qrcodeSucess" @err="qrcodeError" />
	</view>
</template>

<script>
	import QRcode from '../components/QRcode.vue'
	export default {
		components: {
			QRcode
		},
		props: {},
		data() {
			return {

			}
		},
		watch: {},
		// 必须要在onReady生命周期，因为onLoad生命周期组件可能尚未创建完毕
		onReady() {},
		onLoad(options) {},
		onShow() {},
		methods: {
			qrcodeSucess(data) {
				uni.showModal({
					title: '成功',
					content: data,
					success: () => {
						// uni.navigateBack({})
						this.router.push({
							path: '/pages/QRCode/info/index'
						})
					}
				})
			},
			qrcodeError(err) {
				console.log(err)
				uni.showModal({
					title: '摄像头授权失败',
					content: '摄像头授权失败，请检测当前浏览器是否有摄像头权限。',
					success: () => {
						uni.navigateBack({})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		height: 100vh;
		width: 100vw;
	}
</style>